{% extends "base.html" %}

{% block title %}确认解决方案配合{% endblock %}

{% block content %}
<div class="container-fluid">
    <!-- 页面标题 -->
    <div class="d-flex justify-content-between align-items-center mb-4">
        <h1 class="h3">确认解决方案配合</h1>
        <div>
            <a href="{{ url_for('followup.view_followup', followup_id=followup.id) }}" class="btn btn-secondary">
                <i class="fas fa-arrow-left"></i> 返回详情
            </a>
        </div>
    </div>

    <!-- 跟进记录信息 -->
    <div class="card mb-4">
        <div class="card-header">
            <h5 class="mb-0">跟进记录信息</h5>
        </div>
        <div class="card-body">
            <div class="row mb-3">
                <div class="col-md-6">
                    <strong>客户名称：</strong>
                    <a href="{{ url_for('customer.view_customer', customer_id=followup.customer.id) }}" target="_blank">
                        {{ followup.customer.name if followup.customer else '未知客户' }}
                    </a>
                </div>
                <div class="col-md-6">
                    <strong>跟进人：</strong> {{ followup.manager.username if followup.manager else '未知' }}
                </div>
            </div>
            <div class="row mb-3">
                <div class="col-md-6">
                    <strong>跟进时间：</strong> {{ followup.followup_time.strftime('%Y-%m-%d %H:%M') if followup.followup_time else '' }}
                </div>
                <div class="col-md-6">
                    <strong>跟进方式：</strong> <span class="badge bg-info">{{ followup.method }}</span>
                </div>
            </div>
            <div class="mb-3">
                <strong>跟进内容：</strong>
                <div class="mt-2 p-3 bg-light rounded">
                    {{ followup.content | nl2br }}
                </div>
            </div>
            {% if followup.result %}
            <div class="mb-3">
                <strong>跟进结果：</strong>
                <div class="mt-2 p-3 bg-light rounded">
                    {{ followup.result | nl2br }}
                </div>
            </div>
            {% endif %}
        </div>
    </div>

    <!-- 确认配合表单 -->
    <div class="card">
        <div class="card-header">
            <h5 class="mb-0">确认配合</h5>
        </div>
        <div class="card-body">
            <form method="POST">
                {{ form.hidden_tag() }}
                
                <div class="alert alert-info">
                    <i class="fas fa-info-circle"></i> 
                    请确认是否配合此跟进记录的解决方案需求。
                </div>
                
                <div class="mb-4">
                    <div class="form-check">
                        {{ form.confirmed(class="form-check-input") }}
                        {{ form.confirmed.label(class="form-check-label") }}
                    </div>
                    {% if form.confirmed.errors %}
                    <div class="text-danger mt-1">
                        {% for error in form.confirmed.errors %}
                        <small>{{ error }}</small>
                        {% endfor %}
                    </div>
                    {% endif %}
                </div>
                
                <div class="d-flex justify-content-end">
                    <a href="{{ url_for('followup.view_followup', followup_id=followup.id) }}" class="btn btn-secondary me-2">
                        取消
                    </a>
                    <button type="submit" class="btn btn-primary">
                        <i class="fas fa-save"></i> 提交确认
                    </button>
                </div>
            </form>
        </div>
    </div>
</div>
{% endblock %}